
public class demo1 {
    static class Count{
        public int count = 0;
        public void increase(){
            count++;
        }
    }
    public static void main(String[] args) throws InterruptedException {
        Count count = new Count();
        Thread t1 = new Thread(()->{
            for (int i = 0; i < 5000; i++) {
                count.increase();
            }
        });
        Thread t2 = new Thread(()->{
            for (int i = 0; i < 5000; i++) {
                count.increase();
            }
        });
        t1.start();
        t2.start();

        t1.join();
        t2.join();
        System.out.println("Count:"+count.count);
    }
}
